package com.cn.kafka_producer.producer;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;

@Service
public class ProducerService {

    @Autowired
    private KafkaTemplate<String, String> kafkaTemplate;

    public void sendKafkaMq(String str) {
        System.out.println("------------------------------正在发送消息");
        kafkaTemplate.send("test_topic",str);
        System.out.println("------------------------------消息已发送");
    }
}
